package com.csh.user.controller;

import com.csh.user.entity.TbAdmin;
import com.csh.user.entity.TbGoods;
import com.csh.user.entity.dto.AdminEntity;
import com.csh.user.mapper.TbAdminMapper;
import com.csh.user.service.TbAdminService;
import com.csh.utils.ResultResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("/user")
public class UserController {
    @Autowired
    TbAdminService tbAdminService;
    @Autowired
    TbAdminMapper tbAdminMapper;
    @PostMapping("/a")
    public  List<TbAdmin> a(){
        List<TbAdmin> tbAdmins = tbAdminMapper.selectList(null);
        return tbAdmins;
    }
    //账号登录
    @PostMapping("/login")
    public ResultResponse login(@RequestBody AdminEntity adminEntity){
        return tbAdminService.login(adminEntity);
    }
    //获取手机验证码
    @PostMapping("/logins")
    public ResultResponse logins(@RequestBody AdminEntity adminEntity){
        return tbAdminService.logins(adminEntity);
    }
    //验证码登录
    @PostMapping("/dxlogin")
    public ResultResponse dxlogin(@RequestBody AdminEntity adminEntity){

        return tbAdminService.dxlogin(adminEntity);
    }

    /**
     * feign从order调user
     */
    @PostMapping ("/adminIdList")
    public TbAdmin adminIdList(@RequestBody TbAdmin tbAdmin){
        Integer id = tbAdmin.getId();
        TbAdmin tbAdmin1 = tbAdminMapper.selectById(id);
        return tbAdmin1;

    }

}
